package com.tk.scanner;

import java.util.Scanner;

public class Demo06 {
    public static void main(String[] args) {
        //创建一个扫描器对象，用于接收键盘输入数据
        Scanner scanner = new Scanner(System.in);

        int i = 0;
        float f = 0.0F;

        System.out.print("请输入整数：");
        if(scanner.hasNextInt()){
            i = scanner.nextInt();
            System.out.println("整数数据：" + i);
        }else {
            System.out.println("输入的不是整数数据！");
            return;
        }

        System.out.print("请输入小数：");
        if(scanner.hasNextFloat()){
            f = scanner.nextFloat();
            System.out.println("小数数据：" + f);
        }else {
            System.out.println("输入的不是小数数据！");
        }

        scanner.close();
    }
}
